package com.ymatou.iapi.dguser.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.CreateUserBackBean;
import com.ymatou.iapi.dguser.parameter.UpdatepwdBean;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.dguser.service.UpdatepwdCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
/**
*修改登录密码Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_Updatepwd{
	private static UpdatepwdBean updatepwdBean;
	private static UpdatepwdCall updatepwdCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("修改登录密码Test");
	}

	@Before
	public void caseUp() {
		updatepwdBean=new UpdatepwdBean();
		updatepwdCall=new UpdatepwdCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(updatepwdCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Updatepwd_001() {
		Logger.start(true,"正确数据，成功");
		try {
			CreateUserBackBean u = DGUserCallService.initUsercreateNewBean();
			int userId = DGUserCallService.UserCreateNewCall(u);
			updatepwdBean.setUserId(userId);
			updatepwdBean.setPwd("1as1ad23");
			updatepwdCall.setData(updatepwdBean);
			updatepwdCall.callService();			
			Logger.verifyEquals("true", updatepwdCall.getString("success"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Updatepwd_002() {
		Logger.start(true,"纯数字，失败");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(u);
			updatepwdBean.setUserId(userId);
			updatepwdBean.setPwd("11223344");
			updatepwdCall.setData(updatepwdBean);
			updatepwdCall.callService();			
			Logger.verifyEquals("false", updatepwdCall.getString("success"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Updatepwd_003() {
		Logger.start(true,"纯英文字母，失败");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(u);
			updatepwdBean.setUserId(userId);
			updatepwdBean.setPwd("aabbccdd");
			updatepwdCall.setData(updatepwdBean);
			updatepwdCall.callService();			
			Logger.verifyEquals("false", updatepwdCall.getString("success"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Updatepwd_004() {
		Logger.start(true,"位数过短");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(u);
			updatepwdBean.setUserId(userId);
			updatepwdBean.setPwd("11223");
			updatepwdCall.setData(updatepwdBean);
			updatepwdCall.callService();			
			Logger.verifyEquals("false", updatepwdCall.getString("success"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Updatepwd_005() {
		Logger.start(true,"位数过长");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(u);
			updatepwdBean.setUserId(userId);
			updatepwdBean.setPwd("11aa33cc55");
			updatepwdCall.setData(updatepwdBean);
			updatepwdCall.callService();			
			Logger.verifyEquals("false", updatepwdCall.getString("success"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Updatepwd_006() {
		Logger.start(true,"有特殊符号");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(u);
			updatepwdBean.setUserId(userId);
			updatepwdBean.setPwd("11aa！55");
			updatepwdCall.setData(updatepwdBean);
			updatepwdCall.callService();			
			Logger.verifyEquals("false", updatepwdCall.getString("success"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_Updatepwd_007() {
		Logger.start(true,"密码为空，失败");
		try {
			UserCreateBean u = DGUserCallService.initUsercreateBean();
			int userId = DGUserCallService.UserCreateCall(u);
			updatepwdBean.setUserId(userId);
			updatepwdBean.setPwd("");
			updatepwdCall.setData(updatepwdBean);
			updatepwdCall.callService();			
			Logger.verifyEquals("false", updatepwdCall.getString("success"), "验证code");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
}